﻿using System;
using System.Collections.Generic;
using System.Data;
using System.ServiceModel;
using SLS.ExClassLib.Database;
using SLS.ExClassLib.Events;
using SLS.ExClassLib.Message;
using SLS.ExClassLib.RTIService;
namespace SLS.ExClassLib.RTIService
{
    [CallbackBehavior(
    ConcurrencyMode = ConcurrencyMode.Multiple,
    UseSynchronizationContext = false)]
    public class ContactRTIService
    {
         #region =================SINGLETON=================
        /// <summary>
        /// Singleton
        /// </summary>
        public static readonly ContactRTIService Instance = new ContactRTIService();
        public Dictionary<string, object> MessageList;
        /// <summary>
        /// Private constructor for singleton pattern
        /// </summary>
        public ContactRTIService()
        {
            MessageList = new Dictionary<string, object>(); 
        }
        #endregion

        #region =================PROPERTIES================= 
 
        public RTIServiceClient MasterRTIServiceClient
        {
            get;
            set;
        }
        #endregion 

        #region =================METHOD================= 
        public void SendRTIMessage(MessageEx msg, object rtiClient)
        {
            try
            {
                Tracer.Verbose("ContactRTIService.SendRTIMessage", msg.JobID);
                ((RTIServiceClient)rtiClient).SendMAMessage(msg);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public DateTime GetRTITimeStamp(MessageEx msg)
        {
            DateTime timestamp =DateTime.Now;
            return timestamp;
            try
            {
                if (MasterRTIServiceClient != null)
                {
                    timestamp = MasterRTIServiceClient.GetRTITimeStamp(msg).TimeStamp;
                } 
            }
            catch (Exception ex)
            {
                throw;
            }
            return timestamp;
        }
        /// <summary>
        /// Event delegate ReplyReqJob
        /// </summary>  
        #endregion
         
    }
}